<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition template="../TemplateAdmin.xhtml">
        <ui:define name="title">
            <h:outputText value="OrderManager"></h:outputText>
        </ui:define>       
        <ui:define name="body">
            <h:form>           
                <p:growl id="noticeMessage" />  
                <p:dataTable var="item" value="#{orderController.listOrderBySatus()}" editable="true" resizableColumns="true"
                             paginator="true" rows="5" paginatorPosition="bottom" 
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15" style="width:100%" widgetVar="roomTable">
                    <f:facet name="header">
                        <h:outputText value="List of Order" />                            
                        <p:outputPanel style="float: right">
                            <h:outputText value="Search all fields "  />
                            <h:inputText id="globalFilter"  onkeyup="roomTable.filter()"  />
                        </p:outputPanel>
                    </f:facet>
                    <p:ajax event="rowEdit" listener="#{orderController.onEdit}" />
                    <p:ajax event="rowEditCancel" listener="#{orderController.onEditCancel}" />

                    <p:column sortBy="#{item.odID}" headerText="ID" style="width: 30px"
                              >          
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.odID}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.odID}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>  
                    </p:column>

                    <p:column sortBy="#{item.usID.usUserName}" headerText="User"
                              filterMatchMode="exact" filterBy="#{item.usID.usUserName}" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <p:commandLink value="#{item.usID.usUserName}" id="usID" />
                                <p:overlayPanel id="DetailsUserPanel" for="usID" hideEffect="fade" dynamic="true">  
                                    <h:panelGrid columns="2">
                                        <h:outputText value="ID:"/>
                                        <h:outputText value="#{item.usID.usID}" title="ManagerID"/>
                                        <h:outputText value="ManagerName:"/>
                                        <h:outputText value="#{item.usID.usName}" title="ManagerID"/>
                                        <h:outputText value="UserName:"/>
                                        <h:outputText value="#{item.usID.usUserName}" title="UserName"/>
                                        <h:outputText value="Email:"/>
                                        <h:outputText value="#{item.usID.usEmail}" title="Email"/>
                                        <h:outputText value="Address:"/>
                                        <h:outputText value="#{item.usID.usAdress}" title="Address"/>
                                        <h:outputText value="Phone:"/>
                                        <h:outputText value="#{item.usID.usPhone}" title="Phone"/>
                                        <h:outputText value="Status:"/>
                                        <h:outputText value="#{item.usID.usStatus}" title="Status"/>

                                    </h:panelGrid>
                                </p:overlayPanel>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usID.usUserName}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>  
                    </p:column>

                    <c:set var="a" value="#{loginController.managerLogin.mnID}"/> 
                    <p:column sortBy="#{item.mnID.mnName}" headerText="Manager"
                              filterMatchMode="exact" filterBy="#{item.mnID.mnName}"    >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnID.mnName}"/>                                
                            </f:facet>
                            <f:facet name="input" id="mnID">   
                                <h:inputText  id="mnID" value="#{loginController.managerLogin.mnID}" />                                    

                            </f:facet>
                        </p:cellEditor> 
                    </p:column>

                    <p:column sortBy="#{item.odCity}" headerText="City" 
                              filterMatchMode="exact" filterBy="#{item.odCity}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.odCity}"/>
                            </f:facet>
                            <f:facet name="input">   
                                <h:outputText value="#{item.odCity}" />
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column sortBy="#{item.odCountry}" headerText="Country" >
                        <p:cellEditor>
                            <f:facet name="output">         
                                <h:outputText value="#{item.odCountry}"/>                              
                            </f:facet>
                            <f:facet name="input"> 
                                <h:outputText value="#{item.odCountry}"/>                                                    
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column sortBy="#{item.odCreated}" headerText="Created Date"
                              filterMatchMode="exact" filterBy="#{item.odCreated}">                      
                        <p:cellEditor>
                            <f:facet name="output">         
                                <h:outputText value="#{item.odCreated}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </f:facet>
                            <f:facet name="input">   
                                <h:outputText  value="#{item.odCreated}">  
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>                         
                            </f:facet>
                        </p:cellEditor>
                    </p:column>


                    <p:column sortBy="#{item.odTotal}" headerText="Total" >                      
                        <p:cellEditor>
                            <f:facet name="output">         
                                <h:outputText value="#{item.odTotal}"/>                               
                            </f:facet>
                            <f:facet name="input">   
                                <h:outputText value="#{item.odTotal}"/>                            
                            </f:facet>
                        </p:cellEditor>
                    </p:column>
                    <p:column headerText="Status" sortBy="#{item.odStatus}" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="Not check" rendered="#{item.odStatus == 0}"/>
                                <h:outputText value="Successfull" rendered="#{item.odStatus == 1}"/>
                                <h:outputText value="Fail" rendered="#{item.odStatus == 2}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:selectOneMenu value="#{item.odStatus}">
                                    <f:selectItem itemLabel="Not check" itemValue="0"/>
                                    <f:selectItem itemLabel="Successfull" itemValue="1"/>
                                    <f:selectItem itemLabel="Fail" itemValue="2"/>
                                </h:selectOneMenu>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column> 

                    <!--cot hien thi các nút xóa, ...view ...-->
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value=""/>
                        </f:facet>
                        <p:commandButton action="#{orderController.prepareView(item)}"   icon="ui-icon-extlink"                                             
                                         title="Detail" value="Detail"  >
                        </p:commandButton>                       
                    </p:column>
                    <p:column>
                        <p:rowEditor/>
                    </p:column>
                </p:dataTable>
                <br />        
            </h:form>
        </ui:define>
    </ui:composition>
</html>


